package gkaylee

import (
	"encoding/json"
	"reflect"
)

// StructFormat 格式化结构体
func StructFormat(v any) string {
	if reflect.TypeOf(v).Kind() == reflect.Pointer {
		nv := reflect.ValueOf(v).Elem().Interface()
		data, _ := json.MarshalIndent(nv, "", "  ")
		return string(data)
	}
	data, _ := json.MarshalIndent(v, "", "  ")
	return string(data)
}
